package com.example.yls.demoa;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;

public class EditActivity extends AppCompatActivity {
    private EditText edt_Name;
    private EditText edt_Age;
    private RadioButton radio_Button1;
    private RadioButton radio_Button2;
    private RadioButton radio_Button3;
    private RadioButton radio_Button4;
    private RadioButton radio_Button5;
    private Button btnSave;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edit);

        setTitle("编辑学生");

        Intent intent=getIntent();
        String name=intent.getStringExtra("Name");
        int age=intent.getIntExtra("Age",0);
        int ImgId=intent.getIntExtra("Img",R.drawable.dog1);

        edt_Name=findViewById(R.id.edtName);
        edt_Age=findViewById(R.id.edtAge);

        radio_Button1=findViewById(R.id.radioButton1);
        radio_Button2=findViewById(R.id.radioButton2);
        radio_Button3=findViewById(R.id.radioButton3);
        radio_Button4=findViewById(R.id.radioButton4);
        radio_Button5=findViewById(R.id.radioButton5);

        edt_Name.setText(name);
        edt_Age.setText(String.valueOf(age));

        switch (ImgId){
            case R.drawable.dog1:
                radio_Button1.setChecked(true);
                break;

            case R.drawable.dog2:
                radio_Button2.setChecked(true);
                break;

            case R.drawable.dog3:
                radio_Button3.setChecked(true);
                break;

            case R.drawable.dog4:
                radio_Button4.setChecked(true);
                break;

            case R.drawable.dog5:
                radio_Button5.setChecked(true);
                break;
        }
    }
}
